<?PHP
// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | SAPID: XML Sapiens Engine Demonstrator                               |
// +----------------------------------------------------------------------+
// | Author:  Max Baryshnikov aka Mephius <mb@rg.by>	                  |
// | Copyright (c) 2004 Max Baryshnikov                                   |
// | http://sapid.sourceforge.net	                                      |
// +----------------------------------------------------------------------+
// | This source file is free software; you can redistribute it and/or    |
// | modify it under the terms of the GNU Lesser General Public           |
// | License as published by the Free Software Foundation; either         |
// | version 2.1 of the License, or (at your option) any later version.   |
// |                                                                      |
// | This source file is distributed in the hope that it will be useful,  |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
// | Lesser General Public License for more details.                      |
// +----------------------------------------------------------------------+
// Release: 13.11.04 (dd/mm/yy)
// $Id: insert_image.php,v 1.10 2006/06/12 09:53:21 pioneer-hg Exp $
session_start();
header("Content-type: text/html; charset=UTF-8");
if(!isset($_SESSION["user"]["LOGIN"]) or (isset($_SESSION["user"]["NOLOGIN"]) AND $_SESSION["user"]["NOLOGIN"]!="")) die();

include_once("../../etc/rc.conf.php");
if($language=="ru" or $language=="en") $default_language=$language;
if(!$default_language) $default_language="en";

// ROOT_PATH = preg_replace("/usr\/system\/insert_image\.php$/is", "", $_SERVER["SCRIPT_FILENAME"]);
include_once('../../lang/'.$default_language.'.inc.php');


function message_die($message) {
	die('
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>Critical error</title>
	<link rel="stylesheet" type="text/css" href="'.$GLOBALS["http_path"].'usr/system/default.css" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="padding: 0px; margin: 0px;">
<div style="position: absolute; left: 15%; top: 10%">
	<div style="position: absolute; z-index: 2;"><img src="'.$GLOBALS["http_path"].'usr/system/images/girl.gif" width="100" height="193" alt="Beastie girlfriend"></div>
	<div style="padding: 125px 0px 0px 25px;">
	<table class="tpanel" style="width: 90%" cellspacing=0 cellpadding=0>
		<tr>
			<td class="header" style="text-align: center;"><b>Critical error</b></td>
		</tr>
		<tr>
			<td style="padding: 20px; font-family: Verdana, Arial;">
			'.$message.'
			</td>
		</tr>
		<tr>
			<td class="header" align="right">&nbsp;</td>
		</tr>
	</table>
	</div>
</div>
</body>
</html>');
}


function sysB_chkgd2()
{
	$rep=false;
	if(isset($GLOBALS["gBGDVersion"])) {
		$rep=$GLOBALS["gBGDVersion"];
	} else {
		if(function_exists("gd_info")) {
			$gdver=gd_info();
			$GLOBALS["gBGDVersion"]=$rep=preg_replace("/^(.*)(\d+?\.?\d+?\.?)(.*)$/", "\\2", $gdver["GD Version"]);
		} else {
			$arr=get_loaded_extensions();
			if(in_array("gd", $arr) and $im=@imagecreatetruecolor(1,1)) {
				imagedestroy($im);
				$GLOBALS["gBGDVersion"]=$rep="2.0";
			}elseif (in_array("gd", $arr) and $im=@imagecreate(1,1)){
				imagedestroy($im);
				$GLOBALS["gBGDVersion"]=$rep="1.6";
			}
		}
	}
	return $GLOBALS["gBGDVersion"];
}


/**
 * @desc Save POST data
 */
if($_POST)
{

	include('image_resize.inc.php');

	$dcontentpath=ROOT_PATH."usr/templates/images/";
	$dcontentpath_pref=ROOT_PATH."usr/templates/images/";
	$filedname="ImgUrl";
	$filebasename=$_FILES[$filedname]['name'];



	if( preg_match("/\.php$/is", $filebasename) ) $filebasename = $filebasename.".txt";
	if( preg_match("/\.phtml$/is", $filebasename) ) $filebasename = $filebasename.".txt";
	if( preg_match("/\.php3$/is", $filebasename) ) $filebasename = $filebasename.".txt";



	if($HTTP_POST_FILES[$filedname]['tmp_name']!="" && $HTTP_POST_FILES[$filedname]['tmp_name']!="none")
	{

		$newfilename = str_replace("/","_", $_POST["script_uri"]);
		if(!copy($HTTP_POST_FILES[$filedname]['tmp_name'], $dcontentpath_pref.$newfilename.$filebasename)) $error_message=$lang["Can_not_save_uploaded_file"];
		elseif($_POST['flag_icon']) {
			$farr['tmp_name'] = $HTTP_POST_FILES[$filedname]['tmp_name'];
			$farr['name'] = $HTTP_POST_FILES[$filedname]['name'];
			$farr['type'] = $HTTP_POST_FILES[$filedname]['type'];
			$farr['error'] = $HTTP_POST_FILES[$filedname]['error'];
			$farr['size'] = $HTTP_POST_FILES[$filedname]['size'];
			create_tnail($farr, $_POST['icon_width'],$_POST['icon_height'], $dcontentpath_pref, "icon_".$newfilename);
		}
	}

	$content = '<body>
'.( $error_message ? "<br /><br /><br /><br /><div align=\"center\">'".$error_message."'</div>\n" :
'<script language="JavaScript">
	window.opener.frmImagePick.flag_unload_access.value = 1;
	//window.opener.window.close();
	window.close();
</script>
').'
</body>
';
print $content;
exit;
}


if( !file_exists($GLOBALS['root_path'].'usr/templates/images/imgpreview.gif') ) message_die('I can\'t find file /usr/templates/images/imgpreview.gif');
if( !file_exists($GLOBALS['root_path'].'usr/templates/images/dot.swf') ) message_die('I can\'t find file /usr/templates/images/dot.swf');

?>
<html>
<head>
	<title><?=$lang["Insert_Picture"]?></title>
	<style type="text/css">
	 BODY   {margin-left:10; font-family:Verdana; font-size:10pt; background:menu}
	 BUTTON {width:9em}
	 TABLE  {font-family:Verdana; font-size:10pt;}
	 P      {text-align:center}
	</style>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="<?PHP print $http_path; ?>usr/system/default.css">


<script language="JavaScript">
<!--
var imgCaptions = new Array();
var imgHeights = new Array();
var imgWidths = new Array();
var triggerPreview = false;
imgCaptions[0] = "";
imgHeights[0] = "0";
imgWidths[0] = "0";


function IsDigit() {
	return ((event.keyCode >= 48) && (event.keyCode <= 57));
}


function showPreview() {
	if(document.frmImagePick.ImgUrl.value != "")
	document.frmImagePick.BackupImgUrl.value = document.frmImagePick.ImgUrl.value;

	if (document.frmImagePick.BackupImgUrl.value != "")
	{
		triggerPreview = true;
		var arg_arr = document.frmImagePick.BackupImgUrl.value.split(".");
		var arg_ext =  arg_arr[arg_arr.length-1];
		if(arg_ext=="swf" || arg_ext=="SWF") {
			DIVIMG.style.display = "none";
			DIVSWF.style.display = "block";
			document.PREVIEWSWF.Movie=decodeURI(document.frmImagePick.BackupImgUrl.value);
			document.frmImagePick.ImgHeight.value =  document.PREVIEWSWF.clientHeight;
			document.frmImagePick.ImgWidth.value =  document.PREVIEWSWF.clientWidth;
		} else {
			DIVSWF.style.display = "none";
			DIVIMG.style.display = "block";
			document.PREVIEWPIC.src=decodeURI(document.frmImagePick.BackupImgUrl.value);
			document.frmImagePick.ImgHeight.value = document.PREVIEWPIC.height;
			document.frmImagePick.ImgWidth.value = document.PREVIEWPIC.width;
		}

	}
	else
	document.PREVIEWPIC.src='<?=$GLOBALS['http_path']?>usr/templates/images/imgpreview.gif';
}

// -->
</script>


<script language="JavaScript" for="PREVIEWPIC" event="onreadystatechange">
<!--
if(readyState == "complete"){
	PREVIEWPIC.style.visibility = "visible";
	if(document.readyState == "complete"){
		document.frmImagePick.ImgHeight.value = document.PREVIEWPIC.height;
		document.frmImagePick.ImgWidth.value = document.PREVIEWPIC.width;
	}
}
//-->
</script>


<script language="JavaScript" for="window" event="onload">
<!--
document.frmImagePick.BackupImgUrl.value = window.opener.bcwb_form.arg_ImgUrl.value.replace("file:///", "");
showPreview();
document.frmImagePick.AltText.value = window.opener.bcwb_form.arg_AltText.value;
document.frmImagePick.ImgBorder.value = window.opener.bcwb_form.arg_ImgBorder.value;
document.frmImagePick.HorSpace.value = window.opener.bcwb_form.arg_HorSpace.value;
document.frmImagePick.VerSpace.value = window.opener.bcwb_form.arg_VerSpace.value;
document.frmImagePick.ImgHeight.value = window.opener.bcwb_form.arg_ImgHeight.value;
document.frmImagePick.ImgWidth.value = window.opener.bcwb_form.arg_ImgWidth.value;
for(i=1;i<(document.frmImagePick.ImgAlign.length-1);i++)
if(document.frmImagePick.ImgAlign[i].value==window.opener.bcwb_form.arg_ImgAlign.value);
document.frmImagePick.ImgAlign.selectedIndex = i;
clock_status()
// -->
</script>

<script language="JavaScript">
<!--

function FrameUnload() {
	if(frmImagePick.flag_unload_access.value==0) return false;

	var arr = new Array();

	if (triggerPreview==false)
	{
		alert('You did not select a picture. Page not updated.');
		arr=null;
	}
	else
	{
		var arg_AltText = document.frmImagePick.AltText.value;
		var arg_HorSpace = document.frmImagePick.HorSpace.value;
		var arg_VerSpace = document.frmImagePick.VerSpace.value;
		var arg_ImgUrl = false;

		if (document.frmImagePick.ImgUrl.value != "")
		arg_ImgUrl = 'file:///' + document.frmImagePick.ImgUrl.value;
		else
		{
			if( document.frmImagePick.BackupImgUrl.value.substr(0,5) == 'http:' )
			arg_ImgUrl = document.frmImagePick.BackupImgUrl.value;
			else
			arg_ImgUrl = 'file:///' + document.frmImagePick.BackupImgUrl.value;
		}

		var arg_ImgUrl = arg_ImgUrl.split("\\").join("/");
		var arg_arr = arg_ImgUrl.split(".");
		var arg_ext =  arg_arr[arg_arr.length-1];
		var arg_ImgBorder = document.frmImagePick.ImgBorder.value;
		var arg_ImgAlign = document.frmImagePick.ImgAlign[document.frmImagePick.ImgAlign.selectedIndex].value;
		var arg_ImgHeight = document.frmImagePick.ImgHeight.value;
		var arg_ImgWidth = document.frmImagePick.ImgWidth.value;

		var arr = arg_ImgUrl.split("\/");
		var fpref = document.frmImagePick.script_uri.value;
		var imgfname = fpref.split("\/").join("_")+arr[arr.length-1];

		if(arg_ext=="swf" || arg_ext=="SWF") {
			var img_width = document.PREVIEWSWF.clientWidth;
			var img_height = document.PREVIEWSWF.clientHeight;
			var output = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+img_width+'" height="'+img_height+'">' +
			'<param name="movie" value="<?=$http_path?>usr/templates/images/' + imgfname + '">'+
			'<param name="quality" value="high">'+
			'<embed src="<?=$http_path?>usr/templates/images/' + imgfname + '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+img_width+'" height="'+img_height+'">'+
			'</embed>'+
			'</object>';
		} else {

			if(document.frmImagePick.flag_icon.checked)
			var output = unescape("%3C")+'a onclick="window.open(\'<?=$http_path?>preview_image.php?filename=' + imgfname + '\', \'w\', \'status=yes,toolbar=no,menubar=no,resizable=yes\')" style="cursor: pointer"'+unescape("%3E")+unescape("%3C")+'img src="' +
			'<?=$http_path?>usr/templates/images/icon_' + imgfname + '"  alt="' +arg_AltText + '" vspace="' + arg_VerSpace + '" hspace="' + arg_HorSpace +  '" align="' + arg_ImgAlign +'" border="' + arg_ImgBorder + '" /'+unescape("%3E")+unescape("%3C")+'/a'+unescape("%3E");
			else
			var output = unescape("%3C")+'img src="<?=$http_path?>usr/templates/images/' + imgfname + '"  alt="' +arg_AltText + '" vspace="' + arg_VerSpace + '" hspace="' + arg_HorSpace +  '" align="' + arg_ImgAlign +'" border="' + arg_ImgBorder + '" /'+unescape("%3E");
		}

		window.opener.area_<?=$_GET["tag"]?>.focus();
		var mysel = window.opener.area_<?=$_GET["tag"]?>.document.selection;
		if( mysel.type == "Control")  mysel.clear();
		mysel.createRange().pasteHTML( output );
		window.opener.area_<?=$_GET["tag"]?>.focus();
	}

	window.close();
}

var cur_imgname = false;
var cur_imgext = false; // getElementByID()

function ReturnCode() {

	if(cur_imgname==false) return false;
	var arg_AltText = document.frmImagePick.AltText1.value;
	var arg_ImgAlign = document.frmImagePick.ImgAlign1[document.frmImagePick.ImgAlign1.selectedIndex].value;
	if(cur_imgext=="swf" || cur_imgext=="SWF") {
		var img_width = document.PREVIEWSWF1.clientWidth;
		var img_height = document.PREVIEWSWF1.clientHeight;
		var output = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+img_width+'" height="'+img_height+'">' +
		'<param name="movie" value="<?=$http_path?>usr/templates/images/' + cur_imgname + '">'+
		'<param name="quality" value="high">'+
		'<embed src="<?=$http_path?>usr/templates/images/' + cur_imgname + '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+img_width+'" height="'+img_height+'">'+
		'</embed>'+
		'</object>';
	} else {
		var output = unescape("%3C")+'img src="<?=$http_path?>usr/templates/images/' + cur_imgname + '"  alt="' +arg_AltText + '" align="' + arg_ImgAlign +'" border="0" /'+unescape("%3E");
	}



	window.opener.area_<?=$_GET["tag"]?>.focus();
	var mysel = window.opener.area_<?=$_GET["tag"]?>.document.selection;
	if( mysel.type == "Control")  mysel.clear();
	mysel.createRange().pasteHTML( output );
	window.opener.area_<?=$_GET["tag"]?>.focus();
	window.close();
	return false;
}

function clock_status()  {
	window.setTimeout("clock_status()",100);
	if(frmImagePick.flag_unload_access.value==1) FrameUnload();
	today=new Date();
	self.status=today.toString();
}

// -->
</script>

</HEAD>

<body>
<form method="post" target="_blank" name="frmImagePick" id="frmImagePick" encType="multipart/form-data" style="padding-top: 0px; padding-bottom: 0px;">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000">
<input type="hidden" name="BackupImgUrl" value="0">
<input type="hidden" name="flag_unload_access" ID="flag_unload_access" value="0">
<input type="hidden" name="tag" value="<?=$_GET["tag"]?>">
<input type="hidden" name="script_uri" value="">

<div id="mycomputer" align="center">
	<div style="padding-top: 10px; padding-right: 15px; text-align: right; font-size: 14px; height: 28px; background: url(<?=$http_path?>usr/system/images/insimg_bg2.gif) repeat-x;">
	<table width="500" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td width="328"><img src="<?=$GLOBALS['http_path']?>usr/system/images/x.gif" height="1" weight="266" /></td>
		<td valign="top" align="center" width="130">
		<a style="cursor: pointer;" onclick="mysite.style.display='none'; mycomputer.style.display='block';"><?=$lang["MyComputer"];?></a>
		</td>
		<td valign="top" align="center" width="128">
		<a style="cursor: pointer; color: #4B6576;" onclick="mycomputer.style.display='none'; mysite.style.display='block';"><?=$lang["MySite"];?></a>
		</td>
	</tr>
	</table>
	</div>
	<table cellpadding="2" style="margin: 5px 5px 5px 5px" border="0">
	<tr>
		<td valign="top" align="left" nowrap="nowrap">
		<div align="center" style="background-color:gray;overflow:auto;width:450px;height:200px;border-width:1px; border-style:solid;border-color:threeddarkshadow white white threeddarkshadow;">
			<div ID="DIVIMG" style="display: block; border: solid 1px gray">
				<IMG ID="PREVIEWPIC" NAME="PREVIEWPIC" bgcolor="#ffffff" src="<?=$GLOBALS['http_path']?>usr/templates/images/imgpreview.gif" alt="Preview" align="absmiddle" valign="middle" />
			</div>
			<div ID="DIVSWF" style="display: none">
				<object ID="PREVIEWSWF" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0">
				<param name=movie value="<?=$GLOBALS['http_path']?>usr/templates/images/dot.swf">
				<param name="quality" value="high">
				<embed src="<?=$GLOBALS['http_path']?>usr/templates/images/dot.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash">
				</embed>
				</object>
			</div>
		</div>

	</td>
	</tr>
	<tr>
	<td valign="top" align="left" colspan="2" nowrap="nowrap">
	<input type="file" name="ImgUrl" size="40" style="width : 300px;" value="" onChange="showPreview();">
	&nbsp;
	<!--BUTTON class="sapidcms_cont_btn" ONCLICK="showPreview();"><?=$lang["Preview"]?></BUTTON-->
	<br /><?=$lang["Alternate_Text"]?>:<br />
	<input type="text" size="40" name="AltText" style="width : 300px;" />
	</td>
	</tr>

	<tr>
		<td valign="top" align="left" colspan="2">
			<table border="0" cellpadding="2" cellspacing="2">
			<tr>
				<td valign="top" nowrap="nowrap">
				<fieldset style="border: 1px solid #003263; padding : 2px;">
				<legend> <?=$lang["Layout"]?> </legend>
				<table border="0" cellpadding="2" cellspacing="2">
					<tr>
						<td><?=$lang["Alignment"]?>:</td>
						<td>
						<select name="ImgAlign" style="width : 80px;">
							<option value=""></option>
							<option value="left"><?=$lang["Left"]?></option>
							<option value="right"><?=$lang["Right"]?></option>
							<option value="top"><?=$lang["Top"]?></option>
							<option value="middle"><?=$lang["Middle"]?></option>
							<option value="bottom"><?=$lang["Bottom"]?></option>
							<option value=""></option>
						</select>
						</td>
					</tr>
					<tr>
						<td nowrap="nowrap"><?=$lang["Border_Thickness"]?>:</td>
						<td><input type="text" size="2" value="0" name="ImgBorder" inkeypress="event.returnValue=IsDigit();" style="width : 80px;"></td>
					</tr>
				</table>
				</fieldset>
				</td>

				<td valign="top" nowrap="nowrap">
					<fieldset  style="border: 1px solid #003263; padding : 2px;">
					<legend> <?=$lang["Spacing"]?> </legend>
					<table border="0" cellpadding="2" cellspacing="1">
					<tr>
						<td><?=$lang["Horizontal"]?>:</td>
						<td><input type="text" size="2" value="0" name="HorSpace" onkeypress="event.returnValue=IsDigit();" style="width : 80px;"> </td>
					</tr>
					<tr>
						<td><?=$lang["Vertical"]?>:</td>
						<td><input type="text" size="2" value="0" name="VerSpace" onkeypress="event.returnValue=IsDigit();" style="width : 80px;"></td>
					</tr>
					</table>
					</fieldset>
				</td>
			</tr>
			<tr>
				<td colspan="2">
				<fieldset style="border: 1px solid #003263">
				<legend> <?=$lang["Icon"]?> </legend>
				<table width="100%" border="0" cellpadding="2" cellspacing="1">
					<tr>
						<td valign="top">
						<input type="checkbox" <? print ( sysB_chkgd2() ? '': 'disabled') ?> name="flag_icon" value="1" onclick="if(this.checked) icon.style.display='block'; else  icon.style.display='none';" /> <?=$lang["CreateIcon"]?>
						</td>
						<td>
							<table border="0" cellpadding="2" cellspacing="1" ID="icon" style="display: none">
							<tr>
								<td><?=$lang["Width"]?>:</td>
								<td><input type="text" size="2" value="0" name="icon_width" onkeypress="event.returnValue=IsDigit();" style="width : 80px;"> </td>
							</tr>
							<tr>
								<td><?=$lang["Height"]?>:</td>
								<td><input type="text" size="2" value="0" name="icon_height" onkeypress="event.returnValue=IsDigit();" style="width : 80px;"></td>
							</tr>
							</table>
						</td>
					</tr>
				</table>
				</fieldset>
				</td>
			</tr>
			</table>



	</td>
	</tr>
	</table>

	<p align="center">
	<button class="sapidcms_cont_btn" id="Ok" onclick="this.form.submit()">   OK   </button>
	&nbsp;
	<button class="sapidcms_cont_btn" onclick="window.close();"><?=$lang["Cancel"]?></button>
	</p>
	<input type="hidden" size="5" value="0" name="ImgHeight" />
	<input type="hidden" size="5" value="0" name="ImgWidth" />
 </div>


<div id="mysite" style="display: none" align="center">

	<div style="padding-top: 10px; padding-right: 15px; text-align: right; font-size: 14px; height: 28px; background: url(<?=$http_path?>usr/system/images/insimg_bg1.gif) repeat-x;">
	<table width="500" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td width="328"><img src="<?=$GLOBALS['http_path']?>usr/system/images/x.gif" height="1" weight="266" /></td>
		<td valign="top" align="center" width="130">
		<a style="cursor: pointer; color: #4B6576;" onclick="mysite.style.display='none'; mycomputer.style.display='block';"><?=$lang["MyComputer"];?></a>
		</td>
		<td valign="top" align="center" width="128">
		<a style="cursor: pointer" onclick="mycomputer.style.display='none'; mysite.style.display='block';"><?=$lang["MySite"];?></a>
		</td>
	</tr>
	</table>
	</div>

	<table width="300" cellpadding="2" style="margin: 5px 5px 5px 5px" border="0">
	<tr>
		<td colspan="2" valign="top" align="left" nowrap="nowrap">


	<div align="center" style="background-color:gray;overflow:auto;width:450px;height:200px;border-width:1px; border-style:solid;border-color:threeddarkshadow white white threeddarkshadow;">
		<div ID="DIVIMG1" style="display: block; border: solid 1px gray">
			<IMG ID="PREVIEWPIC1" NAME="PREVIEWPIC1" bgcolor="#ffffff" src="<?=$GLOBALS['http_path']?>usr/templates/images/imgpreview.gif" alt="Preview" align="absmiddle" valign="middle" />
		</div>
		<div ID="DIVSWF1" style="display: none">
			<object ID="PREVIEWSWF1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0">
			<param name=movie value="<?=$GLOBALS['http_path']?>usr/templates/images/dot.swf">
			<param name="quality" value="high">
			<embed src="<?=$GLOBALS['http_path']?>usr/templates/images/dot.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash">
			</embed>
			</object>
		</div>
	</div>
		</td>
	</tr>
	<tr>
		<td width="50%" valign="top" align="left" nowrap="nowrap">
		<?=$lang["Alternate_Text"]?>:
		</td>
		<td width="50%" valign="top" align="left" nowrap="nowrap">
		<input type="text" size="40" name="AltText1" style="width : 200px;" />
		</td>

	</tr>

	<tr>
		<td valign="top" align="left" nowrap="nowrap">
		<?=$lang["Alignment"]?>:
		<select name="ImgAlign1" style="width : 80px;">
			<option value=""></option>
			<option value="left"><?=$lang["Left"]?></option>
			<option value="right"><?=$lang["Right"]?></option>
			<option value="top"><?=$lang["Top"]?></option>
			<option value="middle"><?=$lang["Middle"]?></option>
			<option value="bottom"><?=$lang["Bottom"]?></option>
		</select>
		</td>
		<td valign="top" align="left" nowrap="nowrap">
		<input ID="insertbtn" name="insertbtn1" style="display: none" class="sapidcms_cont_btn" type="button" value="<?=$lang["Insert_Picture"]?>" onclick="ReturnCode()" />
		</td>
	</tr>


	<tr>
		<td colspan="2" valign="top" align="left" nowrap="nowrap">

	<div align="left" style="background-color: white; overflow:auto;width:450px;height:200px;border-width:1px; border-style:solid;border-color:threeddarkshadow white white threeddarkshadow; padding: 5px;">
		<table  cellpadding="1" border="0">
		<?PHP
		$d = dir(ROOT_PATH."usr/templates/images/");
		while (false !== ($entry = $d->read())) {
			if($entry!="." AND $entry!=".." AND is_file(ROOT_PATH."usr/templates/images/".$entry)) {
				echo "<tr><td style=\"border-bottom: 1px dotted black\"><a style=\"cursor: pointer;\"
		   	".( preg_match("/\.swf$/is", $entry) ?
		   	"onclick=\"
		   		insertbtn.style.display	 = 'block'; DIVIMG1.style.display = 'none'; DIVSWF1.style.display = 'block'; cur_imgname='$entry'; cur_imgext='swf';
				document.PREVIEWSWF1.Movie=decodeURI('".$http_path."usr/templates/images/".$entry."');
		   	\"" :
		   	"onclick=\"
		   		insertbtn.style.display = 'block'; DIVIMG1.style.display = 'block'; DIVSWF1.style.display = 'none'; cur_imgname='$entry'; cur_imgext='img';
		   	PREVIEWPIC1.src='".$http_path."usr/templates/images/".$entry."';\"" )."
		   	>".$entry."</a></td>\n";
		   	echo "<td style=\"padding-left: 10px; border-bottom: 1px dotted black\">".filesize(ROOT_PATH."usr/templates/images/".$entry)." bytes</td></tr>";
			}
		}
		$d->close();
		?>
		</table>
	</div>


		</td>
	</tr>
	</table>
	</form>
</div>

</body>
</html>